home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / fpoly256.zip / FX3DKIT.H < prev    next >
C/C++ Source or Header  |  1992-01-27  |  5KB  |  135 lines

  1. extern unsigned int dpaddr;        /* video write base */
  2.  
  3. extern unsigned long l_hold, r_hold;          /* used to hold old x data for edge */
  4.  
  5. extern int l_clip;         /* clipping rectangle for polys and lines */
  6. extern int r_clip;      /* max. 0,319,0,199              */
  7. extern int t_clip;
  8. extern int b_clip;
  9.  
  10. typedef struct lp {           /* set of points for clipping or line dwg */
  11.             int x1, y1, x2, y2;
  12.           } lpoints;
  13.  
  14. extern void far vsync();                /* pause till vert. retrace */
  15. extern void far vga_reg(int reg);     /* load VGA register:  */
  16.                     /* reg = reg# + 256*value */
  17.  
  18. extern void far load_color(int color);  /* load VGA color register */
  19. extern void far set_vmode(int mode);    /* set video mode thru BIOS */
  20. extern void far set_vpage(int page);    /* set video page thru BIOS */
  21.  
  22.  
  23. #define PUT 0        /* defines of VGA write modes */
  24. #define AND 1           /* for use with setup_hdwe()  */
  25. #define OR  2
  26. #define XOR 3
  27.  
  28. extern void far setup_hdwe(int mode);  /* setup VGA for bunch of line */
  29.                        /* or poly draws: once per set */
  30.  
  31. extern void far reset_hdwe();  /* reset VGA to BIOS state after drawing */
  32.  
  33.              /* clear video page to solid color: 10 mS */
  34.              /* returns -1 if bad page #         */
  35. extern int far clr_page(int page, int color);
  36.  
  37.             /* copy one page to another for use as */
  38.             /* background: 21 mS per call          */
  39.             /* returns -1 if bad page #            */
  40. extern int far copy_page(int source, int dest);
  41.  
  42.             /* fast VGA line draw: about 15600 24-pixel */
  43.             /* vectors/sec (horizontal much faster)     */
  44. extern void far vgaline(int x1, int y1, int x2, int y2, int color);
  45.  
  46.             /* line draw using lpoint structure   */
  47. extern void vgalines(lpoints *points, int color);
  48.  
  49.             /* Fast Cohen-Sutherland line clipper */
  50.             /* modifies data in points, returns   */
  51.             /* 0 if not clipped, 1 if clipped,    */
  52.             /* -1 if undrawable                   */
  53.             /* 2 - 10 uS per call                 */
  54. extern int clipper (lpoints far *points);
  55.  
  56.             /* does C-S clipping and draws line   */
  57.             /* returns same codes as C-S clipper  */
  58. extern int clipline (lpoints *points, int color);
  59.  
  60. #define NO_HOLD  0      /* values for hold in tpoly() */
  61. #define L_HOLD   1
  62. #define R_HOLD   2
  63. #define HOLD_ALL 3
  64. #define HOLD 0x8000     /* use in x1 or x2 to continue poly side */
  65.  
  66.  
  67. /* NOTE: for all polys, height is 1 less than expected.  This is
  68.    because of the coordinate system used, and aliasing.  So a
  69.    poly with (0,0) (10,0) (0,10) will fill vertical lines 0-9 only.
  70.    This is OK, since real 3D figures consist of overlapping polys.
  71. */
  72.  
  73.             /* draws trapeziodal poly slice FAST   */
  74.             /* x1 is top left, x2 is top right,    */
  75.             /* y1 is top, y3 is bottom.  Clipping  */
  76.             /* is performed.  l_incr and r_incr    */
  77.             /* set slope of sides.               */
  78.             /* if x1 or x2 = HOLD, continues that  */
  79.             /* side from last tpoly call.  Use     */
  80.             /* bits in hold to ensure that needed  */
  81.             /* side data is good in previous tpoly */
  82. extern int far tpoly(int x1,int x2, long l_incr, long r_incr,
  83.                      int y1, int y3, int hold);
  84.  
  85.                    /* compute (x1-x2)/(y1-y2) << 16 */
  86.                    /* used for tpoly...             */
  87.                    /* returns x1-x2 if y1==y2       */
  88. extern long far compute_slope(int x1, int x2, int y1, int y2);
  89.  
  90. void set_gmode();              /* enters 320x200x16 mode, clears screen */
  91. void restore_gmode();          /* enters 320x200x16 mode w/o  clearing screen */
  92. void exit_gmode();             /* exits to text mode */
  93.  
  94. int set_drawpage(int page);    /* set page for drawing on (0-7)   */
  95.  
  96.              /* set displayed page: uses BIOS   */
  97.              /* call, so DON'T use in interrupt */
  98.              /* routines! If WAIT is 1, will    */
  99.              /* sync with vert. retrace (pause) */
  100. int set_vidpage(int page, int wait);
  101.  
  102.             /* fastest triangle poly blitter */
  103.             /* points must be in CCW order   */
  104.             /* (clockwise before Y mirror)   */
  105.             /* and color must have been set  */
  106.             /* with load_color() before call */
  107.             /* NO CLIPPING AT ALL            */
  108. void fastri(int x1, int y1, int x2, int y2, int x3, int y3);
  109.  
  110.             /* N_SIDED POLY DRAW DONE WITH TRIANGLES */
  111.             /* pass pointers to X, Y coord arrays    */
  112.             /* and count.  No clipping, preset color */
  113.             /* with load_color()                     */
  114. void polynt(int *xcoords, int *ycoords, int count);
  115.  
  116.                    /* draw and fill 3-sided polygon    */
  117.                    /* automatically clipped to bounds  */
  118.                    /* not a "pretty poly" fill, so     */
  119.                    /* sliver polys break up.           */
  120.                    /* 5800 polys/sec for 24x24         */
  121. poly3(int x1, int y1, int x2, int y2, int x3, int y3, int color);
  122.  
  123.             /* draw and fill 3-sided polygon    */
  124.             /* automatically clipped to bounds  */
  125.             /* not a "pretty poly" fill, so     */
  126.             /* sliver polys break up.           */
  127.             /* will draw some concave polys OK  */
  128.             /* but can't be depended on esp.    */
  129.             /* if concavity is at top or bot.   */
  130.             /* 3800 30x30 polys/sec             */
  131. poly4(int x1, int y1, int x2, int y2, int x3, int y3,
  132.                     int x4, int y4, int color);
  133.  
  134.  
  135.